package org.coderjonny.controller;

import org.coderjonny.dto.order.OrderParam;
import org.coderjonny.dto.Request;
import org.coderjonny.dto.Result;
import org.coderjonny.dto.order.OrderResult;
import org.coderjonny.service.OrderService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class OrderController {
    @Resource
    private OrderService orderService;
    @PostMapping("/order/create")
    public Result<OrderResult> createOrder(@Validated @RequestBody Request<OrderParam> request){
        OrderResult orderResult = orderService.createOrder(request.getData());
        return Result.ok(orderResult);
    }
}
